package com.rzjm.exercise.module.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rzjm.exercise.common.base.data.DataTableLayUI;
import com.rzjm.exercise.common.base.service.impl.BaseServiceImpl;
import com.rzjm.exercise.module.dao.EventsRecordDao;
import com.rzjm.exercise.module.domain.EventsRecord;
import com.rzjm.exercise.module.service.EventsRecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class EventsRecordServiceImpl extends BaseServiceImpl<EventsRecordDao, EventsRecord> implements EventsRecordService {
    @Resource
    private EventsRecordDao eventsRecordDao;
    @Override
    public DataTableLayUI<EventsRecord> getListPage(DataTableLayUI<EventsRecord> condition) {
        Page<EventsRecord> page = new Page<>(condition.getPage(), condition.getLimit());
        List<EventsRecord> list = eventsRecordDao.getListPage(page, condition.getSearchParams());
        condition.setCount(page.getTotal());
        condition.setData(list);
        condition.setTotalPages(page.getPages());
        condition.setCode(0);
        condition.setMsg("success");
        return condition;
    }

    @Override
    public EventsRecord findDetailById(Integer id) {
        return eventsRecordDao.findDetailById(id);
    }
}
